
A.facebook =
{
    /* */
    init: function()
    {
        FB.init({
            appId: '197228133655811',
            status: true,
            cookie: true,
            xfbml: true
        });

        FB.getLoginStatus(function(response)
        {
            if (response.session)
            {
                A.facebook.getUserInfo(response.session);
            }
            else
            {
                A.event.happened('logout');
            }
        });
    },

    login: function()
    {
        FB.login(function(response)
        {
            if (response.session)
            {
                A.facebook.getUserInfo(response.session);
            }
            else
            {
                A.event.happened('logout');
            }
        });
    },

    /* */
    getUserInfo: function(session)
    {
        //
        FB.api(
            {
              method: 'fql.query',
              query:  'SELECT name, pic_square FROM user WHERE uid=' + session.uid
            },
            function(response)
            {
              A.user.id   = session.uid;
              A.user.name = response[0].name;
              A.user.pic  = response[0].pic_square;

              A.event.happened('login');
            }
        );
    }

};







